const dotenv = require("dotenv")
dotenv.config()
// __webpack_public_path__ = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
// export const qiankun = {
//     // 应用加载之前
//     async bootstrap(props) {
//   console.log('app1 bootstrap', props);
// },
//     // 应用 render 之前触发
//     async mount(props) {
//   console.log('app1 mount', props);
// },
//     // 应用卸载之后触发
//     async unmount(props) {
//   console.log('app1 unmount', props);
// },
//   };
// const remotePath = 'yadea.cd.ecsphere.net';
// const host = 'zion.cd.ecsphere.net';
const host = 'xyl.cd.ecsphere.net';

const CHILD_APPS = {
  mof: {
    port: "8003",
    isRemote: true,
    microApp: "arcvMof",
  },
  bso: {
    port: "8004",
    isRemote: true,
    microApp: "arcvBso",
  },
};

const getApps = () => {
  return Object.keys(CHILD_APPS).map((microSystem) => {
    const { microApp, isRemote, port } = CHILD_APPS[microSystem];
    console.log('xp test 02');
    return {
      name: microApp, // 唯一 id
      entry:
        globalThis.location.href?.indexOf("localhost") >= 0
          ? isRemote
            ? `//${host}/child/${microSystem}/index.html??v=${new Date().getTime()}`
            : `//localhost:${port}`
          : `//${
              globalThis.location.host
            }/child/${microSystem}/index.html?v=${new Date().getTime()}`,
    };
  });
};
const apps = getApps();
console.log('apps', apps);
sessionStorage.setItem('MODULE_KEY', 'arcv');
export const qiankun =  Promise.resolve({
  apps,
    sandbox: true,
    prefetch: false,
    lifeCycles: {
    beforeLoad: (props: any) => {
      console.log('xp test 05', props);
    },
      beforeMount: (props: any) => {
        console.log('xp test 04', props);

      },
    mount: (props: any) => {
      console.log('xp test 03', props);
    },
      afterMount: (props:any) => {
        console.log('asm afterMount', props);
      },
      bootstrap: (props:any)=> {
        console.log('asm bootstrap', props);
      },
  }
})
